home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Java Programmer's Toolkit
/
Java Programmer's Toolkit.iso
/
gs3.53
/
gs_l2img.ps
< prev
next >
Wrap
Text File
|
1996-01-10
|
6KB
|
170 lines
% Copyright (C) 1995 Aladdin Enterprises. All rights reserved.
%
% This file is part of Aladdin Ghostscript.
%
% Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author
% or distributor accepts any responsibility for the consequences of using it,
% or for whether it serves any particular purpose or works at all, unless he
% or she says so in writing. Refer to the Aladdin Ghostscript Free Public
% License (the "License") for full details.
%
% Every copy of Aladdin Ghostscript must include a copy of the License,
% normally in a plain ASCII text file named PUBLIC. The License grants you
% the right to copy, modify and redistribute Aladdin Ghostscript, but only
% under certain conditions described in the License. Among other things, the
% License requires that the copyright notice and this notice be preserved on
% all copies.
% Emulate the Level 2 dictionary-based image operator in Level 1,
% except for Interpolate (ignored) and MultipleDataSources = true;
% also, we require that the data source be either a procedure of a
% particular form or a stream, not a string or a general procedure.
/currentglobal where
{ pop currentglobal { setglobal } true setglobal }
{ { } }
ifelse
7 dict /.csncompdict 1 index def begin
/DeviceGray { 1 /setgray load } bind def
/DeviceRGB { 3 /setrgbcolor load } bind def
/DeviceCMYK { 4 /setcmykcolor load } bind def
/Indexed
{ dup 1 index 1 get //.csncompdict exch get exec
% Stack: [/Indexed base hival map] ncomp basesetcolor
3 -1 roll 3 get mark 3 1 roll
% Stack: ncomp -mark- basesetcolor map
dup type /stringtype eq
{ 3 index
{ -
{ exch round cvi get 255 div
}
-
{ exch round cvi 3 mul 2 copy 2 copy get 255 div
3 1 roll 1 add get 255 div
4 2 roll 2 add get 255 div
}
{ exch round cvi 4 mul 2 copy 2 copy 2 copy get 255 div
3 1 roll 1 add get 255 div
4 2 roll 2 add get 255 div
5 3 roll 3 add get 255 div
}
}
exch get aload pop counttomark -1 roll
}
{ /exec load 3 -1 roll
% -mark- <mapproc> -exec- <basesetcolor>
}
ifelse .packtomark cvx
exch pop 1 exch
} bind def
/Separation
{ dup 2 index //.csncompdict exch get exec
% Stack: [/Separation name alt xform] ncomp altsetcolor
3 -1 roll 3 get /exec load 3 -1 roll 3 array astore readonly cvx
exch pop 1 exch
} bind def
% Substitute device spaces for CIE spaces.
/CIEBasedA /DeviceGray load def
/CIEBasedABC /DeviceRGB load def
/CIEBasedDEF /DeviceRGB load def
/CIEBasedDEFG /DeviceCMYK load def
end
/.packtomark /packedarray where
{ pop { counttomark packedarray exch pop } }
{ { ] readonly } }
ifelse bind def
/.csinextbits % - .csinextbits <bits>
% Uses b, nb, i, row, mask, BitsPerComponent;
% sets b, nb, i.
{ /nb nb
{ dup BitsPerComponent ge { exit } if
/b b 8 bitshift row i get add def
/i i 1 add def 8 add
}
loop
BitsPerComponent sub def
b nb neg bitshift mask and
} bind def
/colorspaceimage % <width> <height> <bits/comp> <matrix>
% <datasrc> <decode> <colorspace> colorspaceimage -
{ save 8 1 roll 20 dict begin
cvlit /colorspace exch def cvlit /Decode exch def
/DataSource exch def cvlit /ImageMatrix exch def
/BitsPerComponent exch def /Height exch def /Width exch def
colorspace dup 0 get .csncompdict exch get exec
/setpixelcolor exch def /ncomp exch def pop
/bpp ncomp BitsPerComponent mul def
/row bpp Width mul 7 add 8 idiv string def
languagelevel 2 gt %****** ge
{ colorspace setcolorspace /ImageType 1 def
currentdict image
}
{ /mask 1 BitsPerComponent bitshift 1 sub def
/nextbits BitsPerComponent 8 eq
{ mark row { i get /i i 1 add def } aload pop .packtomark cvx }
{ /.csinextbits load }
ifelse def
/nextpixel mark 0 2 ncomp 1 sub 2 mul
{ /nextbits cvx exch
Decode exch 2 getinterval
dup aload pop exch sub
dup mask eq { pop } { mask div /mul load 3 -1 roll } ifelse
0 get dup 0 eq { pop } { /sub load 3 -1 roll } ifelse
}
for
/setpixelcolor load dup type /operatortype ne { /exec load } if
.packtomark cvx def
/readrow { DataSource row readstring pop pop }
/DataSource load dup type
dup /arraytype eq exch /packedarraytype eq or
{ % Must be { <file> <string> readhexstring pop }
0 get row /readhexstring load /pop load
4 array astore cvx exch pop
}
{ pop
}
ifelse def
ImageMatrix matrix invertmatrix concat
0 1 Height 1 sub
{ gsave 0 exch translate
readrow
/b 0 def /nb 0 def /i 0 def
Width
{ nextpixel
1 1 true {1 0 0 1 0 0} {<80>} imagemask
1 0 translate
}
repeat grestore
}
for
}
ifelse end restore
} bind def
% Patch for testing.
/.cincompdict 3 dict begin
1 { {0 1} {/DeviceGray} } def
3 { {0 1 0 1 0 1} {/DeviceRGB} } def
4 { {0 1 0 1 0 1 0 1} {/DeviceCMYK} } def
currentdict end def
/colorimage % <width> <height> <bits/comp> <matrix>
% <datasrc> false <ncomp> colorimage -
{ 1 index { /colorimage load /rangecheck signalerror } if exch pop
//.cincompdict exch get exec colorspaceimage
} bind odef
/image
{ dup type /dicttype ne
{ //image }
{ begin /Width load /Height load /BitsPerComponent load
/ImageMatrix load /DataSource load /Decode load currentcolorspace
end colorspaceimage
}
ifelse
} bind odef
exec